import sys,os
from os.path import join

if len(sys.argv) != 3:
    print "USAGE: replaceall.py search replace"
    exit(1)

def getfiles(basedir,dir=''):
    curpath = join(basedir,dir)
    ret = []
    for f in os.listdir(curpath):
        if os.path.isdir(join(curpath,f)):
            ret += getfiles(basedir,join(dir,f))
        else:
            ret.append(join(dir,f))
    return ret
    #print file


for f in getfiles('.'):
    fp = file(f)
    data = fp.read()
    fp.close()
    file(f,'w').write(data.replace(sys.argv[1],sys.argv[2]))

    